<?php
include_once("Elegible.class.php");
include_once('Option.class.php');

class CheckBox extends Elegible
{
	var $input = "<input type=\"checkbox\" name=\"{name}\" value=\"{value}\" id=\"{id}\" {params}{checked} />{text}\n";

	function CheckBox($id, $options = array())
	{
		parent::Elegible($id, $options);
	}

	function __getHTML()
	{
		$inputs = "";
		$search  = array('{name}', '{value}', '{id}', '{params}', '{checked}', '{text}');
		if (count($this->options) == 0)
		{
			$this->options[] = new Option(1, "");
		}
		foreach($this->options as $i => $option)
		{
			$replace = array($this->__getName(), $option->ID, $this->ID.$i, $this->getParams(), $option->tilded ? ' checked' : '', $option->value);
			$inputs .= str_replace($search, $replace, $this->input);
		}

		return $inputs;
	}

	function __getName()
	{
		return $this->getName(). "[]";
	}
}

?>